<template>
	<el-dialog
		:title="title + `-${form.fundCode}-${form.fundFullName}`"
		:visible.sync="addComShow"
		width="70%"
		:before-close="cancel"
		:close-on-click-modal="false"
		:close-on-press-escape="false"
		:top="`${baseInfo.planType === '2' ? '5' : '10'}vh`"
	>
		<div class="windComClass">
			<div class="listItem">
				<div class="listItemChildren">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.isRiskMeasures">
						<span slot="reference">是否有风控措施：预警、止损、最大回撤及其他风控措施等</span>
					</el-popover>
				</div>
				<div class="listItemChildren">
					<el-radio-group v-model="riskInfo.isRiskMeasures" style="width: 100%" disabled>
						<el-radio label="0">是</el-radio>
						<el-radio label="1">否</el-radio>
					</el-radio-group>
				</div>
			</div>

			<div class="listItem">
				<div class="listItemChildren">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.investLeverRate">
						<span slot="reference">投资杠杆率上限（总资产/净资产）%</span>
					</el-popover>
				</div>
				<div class="listItemChildren">
					<el-input v-model="riskInfo.investLeverRate" style="width: 100%" disabled />
				</div>
			</div>

			<div class="listItem" style="width: 100%">
				<div class="listItemChildren" style="width: 25%">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.earlyWarnLine">
						<span slot="reference">有无预警线</span>
					</el-popover>
				</div>
				<div class="listItemChildren" style="width: 75%">
					<el-radio-group v-model="riskInfo.earlyWarnLine" style="width: 100%" disabled>
						<el-radio label="0">有</el-radio>
						<el-radio label="1">无</el-radio>
					</el-radio-group>
				</div>
			</div>

			<template v-if="riskInfo.earlyWarnLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.earlyWarnLineType">
							<span slot="reference">预警线类型 </span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.earlyWarnLineType" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="riskInfo.earlyWarnLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.earlyWarnNetWorth">
							<span slot="reference">预警线对应的资产管理计划净值</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.earlyWarnNetWorth" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<div class="listItem" style="width: 100%">
				<div class="listItemChildren" style="width: 25%">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.stopLossLine">
						<span slot="reference">有无止损线</span>
					</el-popover>
				</div>
				<div class="listItemChildren" style="width: 75%">
					<el-radio-group v-model="riskInfo.stopLossLine" style="width: 100%" disabled>
						<el-radio label="0">有</el-radio>
						<el-radio label="1">无</el-radio>
					</el-radio-group>
				</div>
			</div>

			<template v-if="riskInfo.stopLossLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.stopLossLineType">
							<span slot="reference">止损线类型 </span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.stopLossLineType" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="riskInfo.stopLossLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.stopLossNetWorth">
							<span slot="reference">止损线对应的资产管理计划净值</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.stopLossNetWorth" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<div class="listItem" style="width: 100%">
				<div class="listItemChildren" style="width: 25%">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.maxRetreat">
						<span slot="reference">有无回撤预警线</span>
					</el-popover>
				</div>
				<div class="listItemChildren" style="width: 75%">
					<el-radio-group v-model="riskInfo.maxRetreat" style="width: 100%" disabled>
						<el-radio label="0">有</el-radio>
						<el-radio label="1">无</el-radio>
					</el-radio-group>
				</div>
			</div>

			<template v-if="riskInfo.maxRetreat === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.retreatWarnLineType"
						>
							<span slot="reference">回撤预警线类型 </span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.retreatWarnLineType" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="riskInfo.maxRetreat === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.retreatEarlyWarnNetWorth"
						>
							<span slot="reference">回撤预警线对应的资产管理计划净值</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.retreatEarlyWarnNetWorth" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<div class="listItem" style="width: 100%">
				<div class="listItemChildren" style="width: 25%">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.stopLossWarningLine">
						<span slot="reference">有无回撤止损线</span>
					</el-popover>
				</div>
				<div class="listItemChildren" style="width: 75%">
					<el-radio-group v-model="riskInfo.stopLossWarningLine" style="width: 100%" disabled>
						<el-radio label="0">有</el-radio>
						<el-radio label="1">无</el-radio>
					</el-radio-group>
				</div>
			</div>

			<template v-if="riskInfo.stopLossWarningLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.retreatStopLossLineType"
						>
							<span slot="reference">回撤止损线类型 </span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.retreatStopLossLineType" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="riskInfo.stopLossWarningLine === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.retreatStopLossNetWorth"
						>
							<span slot="reference">回撤止损线对应的资产管理计划净值</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.retreatStopLossNetWorth" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<div class="listItem" style="width: 100%">
				<div class="listItemChildren" style="width: 25%">
					<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.otherRiskStep">
						<span slot="reference">有无其他风控措施</span>
					</el-popover>
				</div>
				<div class="listItemChildren" style="width: 75%">
					<el-radio-group v-model="riskInfo.otherRiskStep" style="width: 100%" disabled>
						<el-radio label="0">有</el-radio>
						<el-radio label="1">无</el-radio>
					</el-radio-group>
				</div>
			</div>

			<template v-if="riskInfo.otherRiskStep === '0'">
				<div class="listItem" style="width: 100%">
					<div class="listItemChildren" style="width: 25%">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.otherRiskExpression"
						>
							<span slot="reference">其他风控措施-合同表述</span>
						</el-popover>
					</div>
					<div class="listItemChildren" style="width: 75%">
						<el-input v-model="riskInfo.otherRiskExpression" type="textarea" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="baseInfo.planType === '2'">
				<div class="listItem" style="width: 100%">
					<div class="listItemChildren" style="width: 25%">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.managerIsInvestment"
						>
							<span slot="reference">管理人是否投入资金</span>
						</el-popover>
					</div>
					<div class="listItemChildren" style="width: 75%">
						<el-radio-group v-model="riskInfo.managerIsInvestment" style="width: 100%" disabled>
							<el-radio label="0">有</el-radio>
							<el-radio label="1">无</el-radio>
						</el-radio-group>
					</div>
				</div>
			</template>

			<template v-if="baseInfo.planType === '2' && riskInfo.managerIsInvestment === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.managerInvestmentAmount"
						>
							<span slot="reference">管理人投入资金参与金额</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.managerInvestmentAmount" style="width: 100%" disabled />
					</div>
				</div>
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.managerInvestmentRatio"
						>
							<span slot="reference">理人投入资金参与比例</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.managerInvestmentRatio" style="width: 100%" disabled />
					</div>
				</div>
			</template>

			<template v-if="baseInfo.planType === '2'">
				<div class="listItem" style="width: 100%">
					<div class="listItemChildren" style="width: 25%">
						<el-popover placement="top-start" width="200" trigger="hover" :content="$store.getters.hoverPerty.riskInfo.managerIsPartake">
							<span slot="reference">管理人附属机构自有资金是否参与</span>
						</el-popover>
					</div>
					<div class="listItemChildren" style="width: 75%">
						<el-radio-group v-model="riskInfo.managerIsPartake" style="width: 100%" disabled>
							<el-radio label="0">有</el-radio>
							<el-radio label="1">无</el-radio>
						</el-radio-group>
					</div>
				</div>
			</template>

			<template v-if="baseInfo.planType === '2' && riskInfo.managerIsPartake === '0'">
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.managerPartakeAmount"
						>
							<span slot="reference">管理人及其附属机构自有资金参与金额（万元）</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.managerPartakeAmount" style="width: 100%" disabled />
					</div>
				</div>
				<div class="listItem">
					<div class="listItemChildren">
						<el-popover
							placement="top-start"
							width="200"
							trigger="hover"
							:content="$store.getters.hoverPerty.riskInfo.managerPartakeRatio"
						>
							<span slot="reference">管理人及其附属机构自有资金参与比例（%）</span>
						</el-popover>
					</div>
					<div class="listItemChildren">
						<el-input v-model="riskInfo.managerPartakeRatio" style="width: 100%" disabled />
					</div>
				</div>
			</template>
		</div>

		<span slot="footer" class="dialog-footer">
			<el-button @click="cancel" :disabled="btnLoading" :loading="btnLoading" size="small">关 闭</el-button>
			<el-button
				v-if="riskInfo.isCheckCompliance !== '0' && title === '复核'"
				type="primary"
				:disabled="btnLoading"
				:loading="btnLoading"
				@click="addConfirm"
				size="small"
				>复 核</el-button
			>
		</span>
	</el-dialog>
</template>
<script>
import { seachStep, checkComliance } from '@/api/productApi/infoMain'
export default {
	props: {
		title: {
			type: String,
			default: ''
		},
		addComShow: {
			type: Boolean,
			default: false
		},
		comIsShow: {
			type: Function,
			default: Function
		},
		getDataList: {
			type: Function,
			default: Function
		}
	},

	data() {
		return {
			riskInfo: {
				isRiskMeasures: '',
				investLeverRate: '',
				earlyWarnLine: '',
				earlyWarnNetWorth: '',
				stopLossLine: '',
				stopLossNetWorth: '',
				maxRetreat: '',
				otherRiskStep: '',
				otherRiskExpression: '',
				managerIsInvestment: '',
				managerInvestmentAmount: '',
				managerInvestmentRatio: '',
				managerIsPartake: '',
				managerPartakeAmount: '',
				managerPartakeRatio: '',
				isCheckCompliance: '',
				earlyWarnLineType: '',
				stopLossLineType: '',
				retreatWarnLineType: '',
				retreatStopLossLineType: '',
				retreatEarlyWarnNetWorth: '',
				retreatStopLossNetWorth: '',
				stopLossWarningLine: ''
			},
			baseInfo: {},
			form: {},
			btnLoading: false
		}
	},

	async created() {
		await this.$store.dispatch('fundStep/setHover')
	},

	methods: {
		cancel() {
			this.riskInfo = {}
			this.baseInfo = {}
			this.form = {}
			this.$emit('comIsShow')
			this.btnLoading = false
		},

		// 新增或编辑
		addConfirm() {
			this.operatorComfirm(() => {
				this.btnLoading = true
				checkComliance({ fundSysCode: this.form.fundSysCode, isCheckCompliance: '0' })
					.then(res => {
						if (res.msgCode === 'Y') {
							this.$message({ message: res.msg, type: 'success' })
							this.$emit('getDataList')
							this.cancel()
						}
					})
					.finally(() => {
						this.btnLoading = false
					})
			}, `复核 “${this.form.fundCode}-${this.form.fundFullName}” 风控信息`)
		},

		edit(obj) {
			const data = {
				fundRaiseType: '2',
				fundSysCode: obj.fundSysCode,
				filedCheckStatus: '0'
			}
			this.form = { ...obj }
			seachStep(data).then(res => {
				if (res.msgCode === 'Y') {
					const productFundInfo = res.data.body.productFundInfo ? res.data.body.productFundInfo : {}
					this.riskInfo = productFundInfo.riskInfo ? productFundInfo.riskInfo : {}
					;['earlyWarnLineType', 'stopLossLineType', 'retreatWarnLineType', 'retreatStopLossLineType'].forEach(item => {
						this.riskInfo[item] = this.riskInfo[item] ? this.riskInfo[item] : '--请选择--'
					})
					this.baseInfo = productFundInfo.baseInfo ? productFundInfo.baseInfo : {}
				}
			})
		}
	}
}
</script>
<style lang="scss" scoped >
.windComClass {
	display: flex;
	flex-wrap: wrap;
	border-left: 1px solid #ced2da;
	border-top: 1px solid #ced2da;
	.listItem {
		width: 50%;
		border-bottom: 1px solid #ced2da;
		display: flex;
		height: 74px;
	}
	.listItemChildren {
		width: 50%;
		border-right: 1px solid #ced2da;
		padding: 10px;
		display: flex;
		align-items: center;
		span {
			font-size: 14px;
			color: #606266;
			font-weight: 600;
		}
	}
}
</style>
